/*
 * @Author: PoJun
 * @Date: 2024-06-20 15:39:41
 * @LastEditors: PoJun
 * @LastEditTime: 2024-07-05 15:27:54
 * @Message: Nothing
 */
module.exports = {
  transpileDependencies: ["@climblee/uv-ui"],
  devServer: {
    port: "8099",
    proxy: {
      "/api": {
        target: process.env.VUE_APP_BASE_API,
        changeOrigin: true,
        pathRewrite: { "^/api": "" }
      },
      "/img": {
        target: process.env.VUE_APP_BASE_IMG_API,
        changeOrigin: true,
        pathRewrite: { "^/img": "" }
      }
    }
  },
  chainWebpack: config => {
    // 发行或运行时启用了压缩时会生效
    config.optimization.minimizer("terser").tap(args => {
      const { compress } = args[0].terserOptions
      // 非 App 平台移除 console 代码(包含所有 console 方法，如 log,debug,info...)
      compress.drop_console = true
      compress.pure_funcs = [
        "__f__" // App 平台 vue 移除日志代码
        // 'console.debug' // 可移除指定的 console 方法
      ]
      return args
    })

    const oneOfsMap = config.module.rule("scss").oneOfs.store
    oneOfsMap.forEach(item => {
      item
        .use("sass-resources-loader")
        .loader("sass-resources-loader")
        .options({
          resources: [
            "./src/scss/common.scss",
            "./src/scss/variables.scss",
            "./src/scss/mixins.scss"
          ]
        })
        .end()
    })
  }
}
